# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name： ip_utility
Description :
Author : 'li'
date： 2021/9/6
-------------------------------------------------
Change Activity:
2021/9/6:
-------------------------------------------------
"""
from IPy import IP
import ipaddress


class IPUtility:
    @staticmethod
    def is_ip_in_subnet(ip, subnet):
        """
        check is ip in subnet
        Args:
            ip:
            subnet:

        Returns:

        """
        _subnet = ipaddress.ip_network(subnet, strict=False)
        ip_set = IP(_subnet.compressed)
        return ip in ip_set


def _main():
    IPUtility.is_ip_in_subnet('10.10.11.10', '10.10.10.12/24')


if __name__ == '__main__':
    _main()
